# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from . import __version__ as app_version

app_name = "erpnext_maxkey_sso"
app_title = "Erpnext Maxkey Sso"
app_publisher = "Your Name"
app_description = "MaxKey Single Sign-On Integration for ERPNext"
app_icon = "octicon octicon-key"
app_color = "blue"
app_email = "your.email@example.com"
app_license = "MIT"

# 为 Desk 添加额外菜单项
# ---------------------
# app_include_js = "/assets/erpnext_maxkey_sso/js/erpnext_maxkey_sso.js"
# app_include_css = "/assets/erpnext_maxkey_sso/css/erpnext_maxkey_sso.css"

# 为网站添加额外菜单项
# ---------------------
website_context = {
    "favicon": "/assets/erpnext_maxkey_sso/images/favicon.ico",
    "splash_image": "/assets/erpnext_maxkey_sso/images/maxkey_logo.png"
}

# 在登录页面引入登录按钮脚本
# 修改这里 - 使用正确的钩子格式
website_include_js = [
    "/assets/erpnext_maxkey_sso/js/maxkey_login_button.js"
]
website_include_css = [
    "/assets/erpnext_maxkey_sso/css/maxkey_sso.css"
]

# 网站脚本
# ------------------
# website_script = "erpnext_maxkey_sso.utils.website_script"

# 安装前执行的钩子
# ------------------------
# before_install = "erpnext_maxkey_sso.install.before_install"
# after_install = "erpnext_maxkey_sso.install.after_install"

# 用户创建的钩子
# --------------------
# 用户创建后执行
# user_after_create = "erpnext_maxkey_sso.oauth.user_after_create"

# 会话创建的钩子
# -----------------------
# 会话创建后执行
on_session_creation = [
    "erpnext_maxkey_sso.oauth.apply_user_permissions"
]

# 定义 OAuth2 提供商
oauth2_providers = [
    {
        "name": "maxkey",
        "flow_params": {
            "authz_uri": "/api/method/erpnext_maxkey_sso.oauth.authorize",
            "token_uri": "/api/method/erpnext_maxkey_sso.oauth.get_token",
            "userinfo_uri": "/api/method/erpnext_maxkey_sso.oauth.get_userinfo",
            "info_uri": "/api/method/erpnext_maxkey_sso.oauth.get_info",
            "callback_uri": "/api/method/erpnext_maxkey_sso.oauth.callback",
            "redirect_uri": "/api/method/erpnext_maxkey_sso.oauth.callback",
            "login_uri": "/api/method/erpnext_maxkey_sso.oauth.login"
        }
    }
]

# 文档事件
# ---------------
doc_events = {
    "*": {
        "on_update": "erpnext_maxkey_sso.erpnext_maxkey_sso.utils.oauth_utils.update_oauth_apps_config",
    }
}

# 每次请求前执行钩子
# ----------------------
# before_request = "erpnext_maxkey_sso.utils.before_request"

# 调度程序事件
# ------------------
# scheduler_events = {
#     "daily": [
#         "erpnext_maxkey_sso.tasks.daily"
#     ],
# }

# 测试
# --------------
# before_tests = "erpnext_maxkey_sso.install.before_tests"

# 区域设置
# ----------
# translations = {
#     "zh-cn": "translations/zh-cn.csv"
# }

